<template>
	<view>
		<Header :showBack="true" title="收货地址"></Header>
		<view class="box">
			<view v-for="(item,index) in list" :key="index">
				<view>
					<view>
						{{item.name}} {{item.phone}}
						<view v-if="item.isDefault">默认</view>
					</view>
					<view>
						{{item.mId}}
					</view>
				</view>
				<view>
					<view @click="checkDefault(item.id)">设为默认</view>
					<view @click="delAdress(item.id)">
						<image src="../../static/img/shanchu.png" mode=""></image>
						删除
					</view>
				</view>
			</view>
		</view>
		<button @click="addAdress" type="default">新建配送地址</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[]
			}
		},
		onShow() {
			this.getList()
		},
		methods: {
			checkDefault(id){
				this.$http('/member/api/mall/setDefaultAddress?id='+id,{
					
				},res=>{
					uni.showToast({
						icon:'none',
						title:'设置成功'
					})
					this.getList()
				})
			},
			delAdress(id){
				this.$http('/member/api/mall/deleteOwnerAddress',[id],res=>{
					this.getList()
				})
			},
			getList(){
				this.$http('/member/api/mall/getOwnerAddressList',{
					 "condition":{}
				},res=>{
					this.list = res.data.items
				})
			},
			addAdress(){
				uni.navigateTo({
					url:'/pages/shopMall/addAddress'
				})
			}
		}
	}
</script>

<style scoped lang="less">
.box{
	width: 100%;
	>view{
		width: 95%;
		background-color: #FFFFFF;
		margin: 20upx auto;
		box-sizing: border-box;
		padding: 40upx  40upx 0;
		border-radius: 16upx;
		// box-shadow: 0 0 15upx rgba(247, 200, 122, .2);
		box-shadow: 0 3upx 20upx 1upx rgba(247, 200, 122, .2);
		>view:first-child{
			border-bottom: 1upx solid #cccccc;
			padding-bottom: 40upx;
			>view:first-child{
				// position: relative;
				display: flex;
				font-weight: 500;
				font-size: 32upx;
				height: 60upx;
				line-height: 60upx;
				align-items: center;
				>view{
					// position: absolute;
					// top: 0;
					// right: 0;
					width: 60upx;
					height: 30upx;
					font-size: 16upx;
					background-color: #FFEFCF;
					color: 	#FFA500;
					border-radius: 15upx;
					line-height: 30upx;
					text-align: center;
					margin-left: 20upx;
				}
			}
			>view:last-child{
				font-size: 26upx;
				color: #aaaaaa;
				min-height: 40upx;
				line-height: 40upx;
			}
		}
		>view:last-child{
			display: flex;
			font-size: 26upx;
			color: #999999;
			justify-content: space-between;
			height: 120upx;
			align-items: center;
			>view:first-child{
				height: 60upx;
				width: 120upx;
				background-color: #49b9ad;
				text-align: center;
				line-height: 60upx;
				color: #FFFFFF;
				border-radius: 8upx;
			}
			>view:last-child{
				display: flex;
				align-items: center;
				>image{
					width: 40upx;
					height: 40upx;
					margin-right: 10upx;
				}
			}
		}
	}
}
button{
	width: 90%;
	height: 80upx;
	line-height: 80upx;
	color: #FFFFFF;
	font-size: 26upx;
	border-radius: 40upx;
	background-color: #49b9ad;
	position: fixed;
	bottom: 50upx;
	left: 50%;
	transform: translate(-50%);
}
</style>
